Show code
pacman::p_load(arrow, lubridate, sf, tidyverse, spNetwork, tmap,
spatstat, raster, maptools)February 4, 2024
We will be applying appropriate spatial point patterns analysis methods learned in class to discover the geographical and spatio-temporal distribution of Grab hailing services locations in Singapore.
The R packages that we will be using in this exercise are as follows:
arrow: For reading parquet files (Grab-Posisi Dataset)
lubridate: To handle the date formatting
sf: Import, manage and process vector-based geospatial data in R.
tidyverse: a collection of packages for data science tasks
spatstat: Wide range of useful functions for point pattern analysis and derive kernel density estimation (KDE) layer.
spNetwork: provides functions to perform Spatial Point Patterns Analysis such as kernel density estimation (KDE) and K-function on network. It also can be used to build spatial matrices (‘listw’ objects like in ‘spdep’ package) to conduct any kind of traditional spatial analysis with spatial weights based on reticular distances.
tmap: Provides functions for plotting cartographic quality static point patterns maps or interactive maps by using leaflet API.
raster: reads, writes, manipulates, analyses and model of gridded spatial data (i.e. raster). In this hands-on exercise, it will be used to convert image output generate by spatstat into raster format.
maptools: Provides a set of tools for manipulating geographic data. In this take-home exercise, we mainly use it to convert Spatial objects into ppp format of spatstat.
# classInt, viridis, rgdal
The datasets that we will be using are as follow:
Using read_parquet() function from arrow package to import the grab data, then changing pingtimestamp column to datetime object
Transforming the coordinate system at the same time when we are importing the data
Reading layer `gis_osm_roads_free_1' from data source
`/Users/jacksontan/Documents/Sashimii0219/IS415-GAA/Take-home_Ex/Take-home_Ex01/data/geospatial'
using driver `ESRI Shapefile'
Simple feature collection with 1759836 features and 10 fields
Geometry type: LINESTRING
Dimension: XY
Bounding box: xmin: 99.66041 ymin: 0.8021131 xmax: 119.2601 ymax: 7.514393
Geodetic CRS: WGS 84
Transforming the coordinate system at the same time when we are importing the data
Reading layer `MPSZ-2019' from data source
`/Users/jacksontan/Documents/Sashimii0219/IS415-GAA/Take-home_Ex/Take-home_Ex01/data/geospatial'
using driver `ESRI Shapefile'
Simple feature collection with 332 features and 6 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 103.6057 ymin: 1.158699 xmax: 104.0885 ymax: 1.470775
Geodetic CRS: WGS 84
Before we begin exploring the data, we will first need to perform some data pre-processing on the datasets that we have imported.
As grab won’t be able to reach offshore places, we will exclude the outer islands from this dataset. We will do this through the following steps:
We will first take a look at the unique planning areas in Singapore using unique() on the PLN_AREA_N column of mpsz2019 dataset.
[1] "MARINA EAST" "RIVER VALLEY"
[3] "SINGAPORE RIVER" "WESTERN ISLANDS"
[5] "MUSEUM" "MARINE PARADE"
[7] "SOUTHERN ISLANDS" "BUKIT MERAH"
[9] "DOWNTOWN CORE" "STRAITS VIEW"
[11] "QUEENSTOWN" "OUTRAM"
[13] "MARINA SOUTH" "ROCHOR"
[15] "KALLANG" "TANGLIN"
[17] "NEWTON" "CLEMENTI"
[19] "BEDOK" "PIONEER"
[21] "JURONG EAST" "ORCHARD"
[23] "GEYLANG" "BOON LAY"
[25] "BUKIT TIMAH" "NOVENA"
[27] "TOA PAYOH" "TUAS"
[29] "JURONG WEST" "SERANGOON"
[31] "BISHAN" "TAMPINES"
[33] "BUKIT BATOK" "HOUGANG"
[35] "CHANGI BAY" "PAYA LEBAR"
[37] "ANG MO KIO" "PASIR RIS"
[39] "BUKIT PANJANG" "TENGAH"
[41] "SELETAR" "SUNGEI KADUT"
[43] "YISHUN" "MANDAI"
[45] "PUNGGOL" "CHOA CHU KANG"
[47] "SENGKANG" "CHANGI"
[49] "CENTRAL WATER CATCHMENT" "SEMBAWANG"
[51] "WESTERN WATER CATCHMENT" "WOODLANDS"
[53] "NORTH-EASTERN ISLANDS" "SIMPANG"
[55] "LIM CHU KANG"

Note that there are 3 areas with island in their name, mainly “NORTH-EASTERN ISLANDS”, “SOUTHERN ISLANDS”, and “WESTERN ISLANDS”.
To exclude the islands, we simply have to pass a condition to exclude these islands in the subset function.
We will be using the st_is_valid() function to test for invalid geometries.
[1] 3
[1] "Ring Self-intersection[26922.5243000389 27027.610899987]"
[2] "Ring Self-intersection[38991.2589000446 31986.5599999869]"
[3] "Ring Self-intersection[14484.6860000313 31330.1319999856]"
We can see that there are 3 invalid geometries. Let’s fix them using st_make_valid().
Simple feature collection with 0 features and 6 fields
Bounding box: xmin: NA ymin: NA xmax: NA ymax: NA
Projected CRS: SVY21 / Singapore TM
[1] SUBZONE_N SUBZONE_C PLN_AREA_N PLN_AREA_C REGION_N REGION_C geometry
<0 rows> (or 0-length row.names)
Using the code above, we can see that there are no missing values.
As the dataset contains data from Malaysia and Brunei as well, we will use st_intersection() to limit the data to only Singapore.
Now, we can see that in points_within_sg it only contain Singapore road data, combined with the other values from mpsz2019 like “PLN_AREA_N” used above.
[1] "osm_id" "code" "fclass" "name" "ref"
[6] "oneway" "maxspeed" "layer" "bridge" "tunnel"
[11] "SUBZONE_N" "SUBZONE_C" "PLN_AREA_N" "PLN_AREA_C" "REGION_N"
[16] "REGION_C" "geometry"
Simple feature collection with 6 features and 16 fields
Geometry type: LINESTRING
Dimension: XY
Bounding box: xmin: 31466.72 ymin: 30680.54 xmax: 32815.21 ymax: 30873.74
Projected CRS: SVY21 / Singapore TM
osm_id code fclass name ref oneway maxspeed layer
4052 23946437 5122 residential Rhu Cross <NA> F 50 0
9668 32605139 5131 motorway_link <NA> <NA> F 40 0
20076 46337834 5131 motorway_link <NA> <NA> F 50 -2
21690 49961799 5111 motorway East Coast Parkway ECP F 70 1
26543 74722808 5111 motorway East Coast Parkway ECP F 70 1
29808 99007260 5131 motorway_link <NA> <NA> F 50 1
bridge tunnel SUBZONE_N SUBZONE_C PLN_AREA_N PLN_AREA_C REGION_N
4052 F F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
9668 F F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
20076 F T MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
21690 F F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
26543 T F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
29808 T F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
REGION_C geometry
4052 CR LINESTRING (31889.45 30760....
9668 CR LINESTRING (32768.57 30857....
20076 CR LINESTRING (32815.21 30873....
21690 CR LINESTRING (32365.45 30845....
26543 CR LINESTRING (31611.63 30720....
29808 CR LINESTRING (31611.63 30720....
Again, using the st_is_valid() function to test for invalid geometries.
[1] 0
character(0)
No invalid geometries!
Simple feature collection with 232766 features and 16 fields
Geometry type: GEOMETRY
Dimension: XY
Bounding box: xmin: 2679.373 ymin: 23099.51 xmax: 50957.8 ymax: 50220.06
Projected CRS: SVY21 / Singapore TM
First 10 features:
osm_id code fclass name ref oneway maxspeed layer
4052 23946437 5122 residential Rhu Cross <NA> F 50 0
9668 32605139 5131 motorway_link <NA> <NA> F 40 0
20076 46337834 5131 motorway_link <NA> <NA> F 50 -2
29808 99007260 5131 motorway_link <NA> <NA> F 50 1
45723 140562813 5131 motorway_link <NA> <NA> F 70 -1
45728 140562819 5131 motorway_link <NA> <NA> F 50 0
45731 140562823 5131 motorway_link <NA> <NA> F 60 -2
45733 140562826 5131 motorway_link <NA> <NA> F 40 0
52966 150819034 5141 service Bay East Drive <NA> B 0 0
84664 174717984 5153 footway <NA> <NA> B 0 0
bridge tunnel SUBZONE_N SUBZONE_C PLN_AREA_N PLN_AREA_C REGION_N
4052 F F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
9668 F F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
20076 F T MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
29808 T F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
45723 F F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
45728 F F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
45731 F T MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
45733 F F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
52966 F F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
84664 F F MARINA EAST MESZ01 MARINA EAST ME CENTRAL REGION
REGION_C geometry
4052 CR LINESTRING (31889.45 30760....
9668 CR LINESTRING (32768.57 30857....
20076 CR LINESTRING (32815.21 30873....
29808 CR LINESTRING (31611.63 30720....
45723 CR LINESTRING (32782.42 30754....
45728 CR LINESTRING (32645.37 30683....
45731 CR LINESTRING (32809.68 30108....
45733 CR LINESTRING (32609.11 30700....
52966 CR LINESTRING (32173.46 30036....
84664 CR LINESTRING (31750.06 30644....
By using the code above, we can see that majority of the missing values are in the ‘name’ and ‘ref’ column. Therefore, let’s drop the irrelevant columns first before we try it again!
We only kept “osm_id”, “code”, “fclass”, and “PLN_AREA_N” columns.
Simple feature collection with 0 features and 4 fields
Bounding box: xmin: NA ymin: NA xmax: NA ymax: NA
Projected CRS: SVY21 / Singapore TM
[1] osm_id code fclass PLN_AREA_N geometry
<0 rows> (or 0-length row.names)
No more missing values here.
Our map so far:
The Grab-Posisi Dataset is an Aspatial dataset, different from the two we prepared above. As such, the pre-processing is slightly different too.
The code below is a chain of dplyr pipes to group the trips by their id and extract the first pingtimestamp row of each trip in order to get the origin of it.
We will need the files in SF format first before we can use it for further geospatial analysis.
Simple feature collection with 0 features and 10 fields
Bounding box: xmin: NA ymin: NA xmax: NA ymax: NA
Projected CRS: SVY21 / Singapore TM
# A tibble: 0 × 11
# Groups: trj_id [0]
# ℹ 11 variables: trj_id <chr>, driving_mode <chr>, osname <chr>,
# pingtimestamp <dttm>, speed <dbl>, bearing <int>, accuracy <dbl>,
# weekday <ord>, start_hr <fct>, day <fct>, geometry <GEOMETRY [m]>
Simple feature collection with 0 features and 10 fields
Bounding box: xmin: NA ymin: NA xmax: NA ymax: NA
Projected CRS: SVY21 / Singapore TM
# A tibble: 0 × 11
# Groups: trj_id [0]
# ℹ 11 variables: trj_id <chr>, driving_mode <chr>, osname <chr>,
# pingtimestamp <dttm>, speed <dbl>, bearing <int>, accuracy <dbl>,
# weekday <ord>, end_hr <fct>, day <fct>, geometry <GEOMETRY [m]>
No missing values, we are almost ready.
To verify that the points that we removed is indeed from the islands, here’s a chunk of code to prove:
# Finding out points removed
diff_id <- origin_sf$trj_id[!(origin_sf$trj_id %in% origin_sf_new$trj_id)]
# Extracting full information of these points
outliers <- origin_sf[(origin_sf$trj_id %in% diff_id), ]
# Checking where these places are from
unique(st_intersection(outliers, mpsz2019)$PLN_AREA_N)[1] "WESTERN ISLANDS" "SOUTHERN ISLANDS"
They are indeed from “WESTERN ISLANDS” and “SOUTHERN ISLANDS”.
Now that our grab dataset is almost ready, we need to decide which column we should drop. Here are the columns in both origin_sf_new and dest_sf_new:
[1] "trj_id" "driving_mode" "osname" "pingtimestamp"
[5] "speed" "bearing" "accuracy" "weekday"
[9] "start_hr" "day" "SUBZONE_N" "SUBZONE_C"
[13] "PLN_AREA_N" "PLN_AREA_C" "REGION_N" "REGION_C"
[17] "geometry"
[1] "trj_id" "driving_mode" "osname" "pingtimestamp"
[5] "speed" "bearing" "accuracy" "weekday"
[9] "end_hr" "day" "SUBZONE_N" "SUBZONE_C"
[13] "PLN_AREA_N" "PLN_AREA_C" "REGION_N" "REGION_C"
[17] "geometry"
We will definitely be dropping the columns merged from mpsz2019_new (other than PLN_AREA_N), but what about “driving_mode”, “osname”, “speed”, “bearing”, and “accuracy”? Let’s first take a look at them.
Seeing that there is only 1 constant in the column, it is safe for us to drop this column.
There are 2 values, mainly “ios” and “android”. Arguments can be made that we can analyse the behavior of both type in terms of using grab hailing services, but that’s not what we will doing so we will drop this as well.
As we are analysing start/stop points, speed will not be a relevant factor hence we will be dropping them.
Not relevant as well, hence dropping.
According to research paper published on Grab website, this is the definition of the accuracy column:
“…the accuracy level roughly indicates the radius of the circle within which the true location lies with a certain probability. The lower the accuracy level, the more precise the reported GPS ping is.”
With that, let’s take a look at the distribution of accuracy score.


From the plot, we can see that there are 3 clear outliers with accuracy above 180~ for origin_sf_new, and 1 for dest_sf_new. Now let’s extract these trips.
Simple feature collection with 3 features and 16 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 18132.25 ymin: 30203 xmax: 28937.76 ymax: 36948.91
Projected CRS: SVY21 / Singapore TM
# A tibble: 3 × 17
trj_id driving_mode osname pingtimestamp speed bearing accuracy
<chr> <chr> <chr> <dttm> <dbl> <int> <dbl>
1 78815 car ios 2019-04-21 13:20:13 0.000000101 68 200
2 67866 car ios 2019-04-18 16:46:16 -1 13 547
3 4579 car ios 2019-04-21 10:35:22 13.0 108 200
# ℹ 10 more variables: weekday <ord>, start_hr <fct>, day <fct>,
# SUBZONE_N <chr>, SUBZONE_C <chr>, PLN_AREA_N <chr>, PLN_AREA_C <chr>,
# REGION_N <chr>, REGION_C <chr>, geometry <POINT [m]>
Simple feature collection with 1 feature and 16 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 33721.09 ymin: 34502.5 xmax: 33721.09 ymax: 34502.5
Projected CRS: SVY21 / Singapore TM
# A tibble: 1 × 17
trj_id driving_mode osname pingtimestamp speed bearing accuracy weekday
<chr> <chr> <chr> <dttm> <dbl> <int> <dbl> <ord>
1 68340 car ios 2019-04-12 11:55:48 -1 10 1414 Fri
# ℹ 9 more variables: end_hr <fct>, day <fct>, SUBZONE_N <chr>,
# SUBZONE_C <chr>, PLN_AREA_N <chr>, PLN_AREA_C <chr>, REGION_N <chr>,
# REGION_C <chr>, geometry <POINT [m]>
To ensure that our data is of utmost accuracy, we will drop these trips, before we drop the accuracy column as well (as we will not need it anymore).
With that done, we can now drop the columns that we don’t need.
Lastly, let’s check for duplicated points on the map.
[1] FALSE
[1] 0
No duplicated points!
It is important for the data to be in the right coordinate reference system (CRS). In this assignment, all spatial data will be projected in EPSG:3414, which is a projected coordinate system for Singapore.
Coordinate Reference System:
User input: EPSG:3414
wkt:
PROJCRS["SVY21 / Singapore TM",
BASEGEOGCRS["SVY21",
DATUM["SVY21",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4757]],
CONVERSION["Singapore Transverse Mercator",
METHOD["Transverse Mercator",
ID["EPSG",9807]],
PARAMETER["Latitude of natural origin",1.36666666666667,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",103.833333333333,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",1,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",28001.642,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",38744.572,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["northing (N)",north,
ORDER[1],
LENGTHUNIT["metre",1]],
AXIS["easting (E)",east,
ORDER[2],
LENGTHUNIT["metre",1]],
USAGE[
SCOPE["Cadastre, engineering survey, topographic mapping."],
AREA["Singapore - onshore and offshore."],
BBOX[1.13,103.59,1.47,104.07]],
ID["EPSG",3414]]
Coordinate Reference System:
User input: EPSG:3414
wkt:
PROJCRS["SVY21 / Singapore TM",
BASEGEOGCRS["SVY21",
DATUM["SVY21",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4757]],
CONVERSION["Singapore Transverse Mercator",
METHOD["Transverse Mercator",
ID["EPSG",9807]],
PARAMETER["Latitude of natural origin",1.36666666666667,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",103.833333333333,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",1,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",28001.642,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",38744.572,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["northing (N)",north,
ORDER[1],
LENGTHUNIT["metre",1]],
AXIS["easting (E)",east,
ORDER[2],
LENGTHUNIT["metre",1]],
USAGE[
SCOPE["Cadastre, engineering survey, topographic mapping."],
AREA["Singapore - onshore and offshore."],
BBOX[1.13,103.59,1.47,104.07]],
ID["EPSG",3414]]
Coordinate Reference System:
User input: EPSG:3414
wkt:
PROJCRS["SVY21 / Singapore TM",
BASEGEOGCRS["SVY21",
DATUM["SVY21",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4757]],
CONVERSION["Singapore Transverse Mercator",
METHOD["Transverse Mercator",
ID["EPSG",9807]],
PARAMETER["Latitude of natural origin",1.36666666666667,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",103.833333333333,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",1,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",28001.642,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",38744.572,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["northing (N)",north,
ORDER[1],
LENGTHUNIT["metre",1]],
AXIS["easting (E)",east,
ORDER[2],
LENGTHUNIT["metre",1]],
USAGE[
SCOPE["Cadastre, engineering survey, topographic mapping."],
AREA["Singapore - onshore and offshore."],
BBOX[1.13,103.59,1.47,104.07]],
ID["EPSG",3414]]
Coordinate Reference System:
User input: EPSG:3414
wkt:
PROJCRS["SVY21 / Singapore TM",
BASEGEOGCRS["SVY21",
DATUM["SVY21",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4757]],
CONVERSION["Singapore Transverse Mercator",
METHOD["Transverse Mercator",
ID["EPSG",9807]],
PARAMETER["Latitude of natural origin",1.36666666666667,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",103.833333333333,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",1,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",28001.642,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",38744.572,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["northing (N)",north,
ORDER[1],
LENGTHUNIT["metre",1]],
AXIS["easting (E)",east,
ORDER[2],
LENGTHUNIT["metre",1]],
USAGE[
SCOPE["Cadastre, engineering survey, topographic mapping."],
AREA["Singapore - onshore and offshore."],
BBOX[1.13,103.59,1.47,104.07]],
ID["EPSG",3414]]
They are all in the correct CRS!
Finally, plotting all three datasets together to ensure that they have a consistent projection system.
Before we begin our Geospatial Analysis, let’s first take a closer look at the Grab dataset.
The distribution of the trips across all 7 days of the week looks even.
First let us look at the top 10 planning areas for grab ride origin points. Tampines is the Planning Area with the most origin points.
origin_pl_area <- origin_sf_new %>%
group_by(PLN_AREA_N) %>%
summarise(total_count=n()) %>%
top_n(10, total_count) %>%
.$PLN_AREA_N
ggplot(origin_sf_new[origin_sf_new$PLN_AREA_N %in% origin_pl_area,],
aes(x=PLN_AREA_N)) + geom_bar() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
labs(title = "Trips Origin Distribution by Planning Area",
x = "Planning Area",
y = "Number of Trips")
Then for the destination points.
dest_pl_area <- dest_sf_new %>%
group_by(PLN_AREA_N) %>%
summarise(total_count=n()) %>%
top_n(10, total_count) %>%
.$PLN_AREA_N
ggplot(dest_sf_new[dest_sf_new$PLN_AREA_N %in% dest_pl_area,],
aes(x=PLN_AREA_N)) + geom_bar() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
labs(title = "Trips Destination Distribution by Planning Area",
x = "Planning Area",
y = "Number of Trips")
6 out of 10 of the Planning Areas remains the same for destination points, mainly TAMPINES, WOODLANDS, YISHUN, QUEENSTOWN, BUKIT MERAH, and CHANGI. This time however, the Planning Area with the most destination points is Changi.

From the graph, we can see that the starting hour peaks at midnight (12am - 1am) and morning (9am - 10am), the former probably due to the lack of public transport after operating hours, and the latter from rush hour.
In the code chunk below, as.ppp() function is used to derive a ppp object layer directly from a sf tibble data.frame.
Marked planar point pattern: 27872 points
Average intensity 2.636568e-05 points per square unit
Coordinates are given to 3 decimal places
i.e. rounded to the nearest multiple of 0.001 units
marks are of type 'character'
Summary:
Length Class Mode
27872 character character
Window: rectangle = [3661.47, 49845.23] x [26795.39, 49685.08] units
(46180 x 22890 units)
Window area = 1057130000 square units
Marked planar point pattern: 27820 points
Average intensity 2.642188e-05 points per square unit
Coordinates are given to 3 decimal places
i.e. rounded to the nearest multiple of 0.001 units
marks are of type 'character'
Summary:
Length Class Mode
27820 character character
Window: rectangle = [3638.69, 50024.92] x [26770.54, 49469.41] units
(46390 x 22700 units)
Window area = 1052920000 square units
In the code chunk as.owin() is used to create an owin object class from polygon sf tibble data.frame. In this case, we will be converting the sg_boundary polygon.
We will now combine singapore’s boundary and the origin and destination points into one.
Marked planar point pattern: 27820 points
Average intensity 4.185996e-05 points per square unit
Coordinates are given to 3 decimal places
i.e. rounded to the nearest multiple of 0.001 units
marks are of type 'character'
Summary:
Length Class Mode
27820 character character
Window: polygonal boundary
37 separate polygons (29 holes)
vertices area relative.area
polygon 1 12666 6.63014e+08 9.98e-01
polygon 2 285 1.61128e+06 2.42e-03
polygon 3 27 1.50315e+04 2.26e-05
polygon 4 (hole) 41 -4.01660e+04 -6.04e-05
polygon 5 (hole) 317 -5.11280e+04 -7.69e-05
polygon 6 (hole) 3 -4.14099e-04 -6.23e-13
polygon 7 30 2.80002e+04 4.21e-05
polygon 8 (hole) 4 -2.86396e-01 -4.31e-10
polygon 9 (hole) 3 -1.81439e-04 -2.73e-13
polygon 10 (hole) 3 -8.68789e-04 -1.31e-12
polygon 11 (hole) 3 -5.99535e-04 -9.02e-13
polygon 12 (hole) 3 -3.04561e-04 -4.58e-13
polygon 13 (hole) 3 -4.46076e-04 -6.71e-13
polygon 14 (hole) 3 -3.39794e-04 -5.11e-13
polygon 15 (hole) 3 -4.52043e-05 -6.80e-14
polygon 16 (hole) 3 -3.90173e-05 -5.87e-14
polygon 17 (hole) 3 -9.59850e-05 -1.44e-13
polygon 18 (hole) 4 -2.54488e-04 -3.83e-13
polygon 19 (hole) 4 -4.28453e-01 -6.45e-10
polygon 20 (hole) 4 -2.18616e-04 -3.29e-13
polygon 21 (hole) 5 -2.44411e-04 -3.68e-13
polygon 22 (hole) 5 -3.64686e-02 -5.49e-11
polygon 23 71 8.18750e+03 1.23e-05
polygon 24 (hole) 6 -8.37554e-01 -1.26e-09
polygon 25 (hole) 38 -7.79904e+03 -1.17e-05
polygon 26 (hole) 3 -3.41897e-05 -5.14e-14
polygon 27 (hole) 3 -3.65499e-03 -5.50e-12
polygon 28 (hole) 3 -4.95057e-02 -7.45e-11
polygon 29 91 1.49663e+04 2.25e-05
polygon 30 (hole) 5 -2.92235e-04 -4.40e-13
polygon 31 (hole) 3 -7.43616e-06 -1.12e-14
polygon 32 (hole) 270 -1.21455e+03 -1.83e-06
polygon 33 (hole) 19 -4.39650e+00 -6.62e-09
polygon 34 (hole) 35 -1.38385e+02 -2.08e-07
polygon 35 (hole) 23 -1.99656e+01 -3.00e-08
polygon 36 71 5.63061e+03 8.47e-06
polygon 37 10 1.99717e+02 3.01e-07
enclosing rectangle: [2667.54, 55941.94] x [21448.47, 50256.33] units
(53270 x 28810 units)
Window area = 664597000 square units
Fraction of frame area: 0.433
The density values of the output range from 0 to 0.000035 which is way too small to comprehend, and it is computed in “number of points per square meter”. Therefore, we are going to use rescale() to covert the unit of measurement from meter to kilometer.
We will first compute the kernel density by using density() of the spatstat package, with the default method bw.diggle().

Looking at all the different methods, we can see that bw.diggle() is still the best among the automatic bandwidth selection method.
Having tried automatic bandwidth selection method, let’s try computing KDE by using a fixed bandwidth defined by us. In our case, we will define a fixed bandwidth of 800m (or 0.8km).
Fixed bandwidth method, however, is very sensitive to highly skewed distribution of spatial point patterns over geographical units, for example urban versus rural. To overcome this, we can try using adaptive bandwidth instead.
As the KDE layer using fixed bandwidth with gaussian kernel plots a graph that allows for meaningful analysis at a glance, we will be using that for the steps moving forward.



In order for us to map the KDE layer of these points to our map, we first need to convert it into grid object.
We will then convert the gridded kernel density objects into RasterLayer object by using raster() of raster package. As the RasterLayer object does not include CRS information, we will need to manually assign it to them as well.
class : RasterLayer
dimensions : 128, 128, 16384 (nrow, ncol, ncell)
resolution : 0.4162063, 0.2250614 (x, y)
extent : 2.667538, 55.94194, 21.44847, 50.25633 (xmin, xmax, ymin, ymax)
crs : +proj=tmerc +lat_0=1.36666666666667 +lon_0=103.833333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +datum=WGS84 +units=km +no_defs
source : memory
names : v
values : -1.923671e-14, 596.2208 (min, max)
class : RasterLayer
dimensions : 128, 128, 16384 (nrow, ncol, ncell)
resolution : 0.4162063, 0.2250614 (x, y)
extent : 2.667538, 55.94194, 21.44847, 50.25633 (xmin, xmax, ymin, ymax)
crs : +proj=tmerc +lat_0=1.36666666666667 +lon_0=103.833333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +datum=WGS84 +units=km +no_defs
source : memory
names : v
values : -7.516604e-15, 520.156 (min, max)
To further explore the map, we will now be overlaying the KDE layer both onto OpenStreetMap of Singapore, and also on the Singapore Planning Area layer and OSM road layer that we have pre-processed.
As you can see from the plot, there are certain planning areas that are hotspots for hailing of Grab ride service, in particular Central Region (Orchard, Newton etc), Woodlands, Punggol, Tampines, and most notably Changi (where the airport lies).
To further confirm our observation, let’s plot the KDE layer over our Planning Area and OSM Road Layers.
The common overlapping Planning Areas include “TAMPINES”, “CHANGI”, “WOODLANDS”, and “NOVENA”, so let’s do a further analysis on these areas.
To do in-depth KDE computation on these 4 planning areas, we will first need to extract their respective boundaries. In the code below, we extracted their boundaries and converted them to sp’s Spatial* class.
Plotting down these boundaries.

Turning the spatial point data frame into generic sp format, then into owin object as done previously.
By using the code below, we will be able to extract grab origin and destination points for these specific areas.
Next up is the rescale() function used previously as well.
origin_cg_ppp.km = rescale(origin_cg_ppp, 1000, "km")
origin_tp_ppp.km = rescale(origin_tp_ppp, 1000, "km")
origin_wl_ppp.km = rescale(origin_wl_ppp, 1000, "km")
origin_nv_ppp.km = rescale(origin_nv_ppp, 1000, "km")
dest_cg_ppp.km = rescale(dest_cg_ppp, 1000, "km")
dest_tp_ppp.km = rescale(dest_tp_ppp, 1000, "km")
dest_wl_ppp.km = rescale(dest_wl_ppp, 1000, "km")
dest_nv_ppp.km = rescale(dest_nv_ppp, 1000, "km")Finally, we plot the four planning areas and the grab hailing origin and destination points
par(mfrow=c(2,4))
plot(origin_cg_ppp.km, main = "CHANGI ORIGIN")
plot(origin_tp_ppp.km, main = "TAMPINES ORIGIN")
plot(origin_wl_ppp.km, main = "WOODLANDS ORIGIN")
plot(origin_nv_ppp.km, main = "NOVENA ORIGIN")
plot(dest_cg_ppp.km, main = "CHANGI DESTINATION")
plot(dest_tp_ppp.km, main = "TAMPINES DESTINATION")
plot(dest_wl_ppp.km, main = "WOODLANDS DESTINATION")
plot(dest_nv_ppp.km, main = "NOVENA DESTINATION")
We will now be computing the KDE of each planning area using the fixed bandwidth method.


The hotspot in Changi area is centered around Changi Airport, indicating a likely surge in use of Grab services due to the constant flow of passengers arriving and departing from Singapore.


The hotspot in Tampines area is mainly concentrated around the stretch from Tampines West to Tampines East, encompassing the bulk of where most residents of Tampines currently live (Tampines West, Tampines, Tampines East).


The rides are concentrated around the lower half of Woodlands area, ranging from Woodlands West to Woodlands South, then Woodlands East. However, one prominent hotspot shared across both the origin and destination map is the Woodlands West region, indicating that this might either be the area with the wealthiest residents in Woodlands, or that there are just more residents concentrated here.


The Novena area’s notable hotspots present an interesting distinction. Origin points predominantly converge around the affluent Moulmein area, revealing a concentration in the wealthier section of town. Conversely, the destination points gravitate towards the Malcolm area, characterized by a cluster of prestigious schools, as illustrated in the figure below.


In this section, we will perform the Clark-Evans test of aggregation for a spatial point pattern by using clarkevans.test() of statspat package, to test whether the distribution of Grab ride hailing origin points are randomly distributed.
Using 95% confidence interval, the test hypotheses are:
Ho = The distribution of Grab ride hailing origin points are randomly distributed.
H1= The distribution of Grab ride hailing origin points are not randomly distributed.
For this section, we will be making use of the ppp object.
Having performed the Clark-Evans Test on all 4 planning area and Singapore as a whole, all of their p-values are <2.2e-16 < 0.05, thus we reject Ho. This means that the distribution of Grab ride hailing origin points are not randomly distributed which we explored in earlier sections.
Furthermore, as their R value ranges from 0.11647 to 0.35838 which is <1, this suggests that the points are clustering.
In this section, we will be using appropriate functions of spNetwork package:
where in this case the network refers to OSM’s Road Map of Singapore.
However, due to limitations in computational power, we will be limiting the area of scope down to the 4 areas identified in the previous section, Changi, Tampines, Woodlands, and Novena, and only the Origin points.
Before we begin, let us first convert our sg_roads_new data from SFC_GEOMETRY to SFC_LINESTRING.
Then, let us narrow down the scope of our data to the 4 areas mentioned.
# Roads
cg_roads <- sg_roads_linestring %>% filter(PLN_AREA_N == "CHANGI")
tp_roads <- sg_roads_linestring %>% filter(PLN_AREA_N == "TAMPINES")
wl_roads <- sg_roads_linestring %>% filter(PLN_AREA_N == "WOODLANDS")
nv_roads <- sg_roads_linestring %>% filter(PLN_AREA_N == "NOVENA")
# Grab Origin Points
cg_origin <- origin_sf_new %>% filter(PLN_AREA_N == "CHANGI")
tp_origin <- origin_sf_new %>% filter(PLN_AREA_N == "TAMPINES")
wl_origin <- origin_sf_new %>% filter(PLN_AREA_N == "WOODLANDS")
nv_origin <- origin_sf_new %>% filter(PLN_AREA_N == "NOVENA")Before we begin our analysis, let us visualise our geospatial data to make sure everything falls into place.
We will now perform NetKDE analysis by using appropriate functions provided in spNetwork package.
Next, we will use lines_center() of spNetwork to generate a SpatialPointsDataFrame (i.e. samples) with line centre points.
We are now ready to compute NetKDE. As the code is fairly long, we will split it into 4 tabs.
# Origin
cg_o_densities <- nkde(cg_roads,
events = cg_origin,
w = rep(1,nrow(cg_origin)),
samples = cg_lines_center,
kernel_name = "quartic", # kernel method
bw = 300,
div= "bw",
method = "simple",
# method used to calculate NKDE. spNetwork supports 3 popular methods, namely simple, discontinuous, and continuous
digits = 1,
tol = 1,
grid_shape = c(1,1),
max_depth = 8,
agg = 5,
# we aggregate events within a 5m radius (faster calculation)
sparse = TRUE,
verbose = FALSE)tp_o_densities <- nkde(tp_roads,
events = tp_origin,
w = rep(1,nrow(tp_origin)),
samples = tp_lines_center,
kernel_name = "quartic", # kernel method
bw = 300,
div= "bw",
method = "simple",
# method used to calculate NKDE. spNetwork supports 3 popular methods, namely simple, discontinuous, and continuous
digits = 1,
tol = 1,
grid_shape = c(1,1),
max_depth = 8,
agg = 5,
# we aggregate events within a 5m radius (faster calculation)
sparse = TRUE,
verbose = FALSE)wl_o_densities <- nkde(wl_roads,
events = wl_origin,
w = rep(1,nrow(wl_origin)),
samples = wl_lines_center,
kernel_name = "quartic", # kernel method
bw = 300,
div= "bw",
method = "simple",
# method used to calculate NKDE. spNetwork supports 3 popular methods, namely simple, discontinuous, and continuous
digits = 1,
tol = 1,
grid_shape = c(1,1),
max_depth = 8,
agg = 5,
# we aggregate events within a 5m radius (faster calculation)
sparse = TRUE,
verbose = FALSE)nv_o_densities <- nkde(nv_roads,
events = nv_origin,
w = rep(1,nrow(nv_origin)),
samples = nv_lines_center,
kernel_name = "quartic", # kernel method
bw = 300,
div= "bw",
method = "simple",
# method used to calculate NKDE. spNetwork supports 3 popular methods, namely simple, discontinuous, and continuous
digits = 1,
tol = 1,
grid_shape = c(1,1),
max_depth = 8,
agg = 5,
# we aggregate events within a 5m radius (faster calculation)
sparse = TRUE,
verbose = FALSE)Before we are able to visualise, we first need to insert the computed values back into lines_center and lixels objects as density field.
cg_lines_center$o_density <- cg_o_densities
cg_lixels$o_density <- cg_o_densities
tp_lines_center$o_density <- tp_o_densities
tp_lixels$o_density <- tp_o_densities
wl_lines_center$o_density <- wl_o_densities
wl_lixels$o_density <- wl_o_densities
nv_lines_center$o_density <- nv_o_densities
nv_lixels$o_density <- nv_o_densitiesSince svy21 projection system is in meter, the computed density values are very small i.e. 0.0000005. We will thus need to rescale the density values from number of events per meter to number of events per kilometer.
cg_lines_center$o_density <- cg_lines_center$o_density*1000
cg_lixels$o_density <- cg_lixels$o_density*1000
tp_lines_center$o_density <- tp_lines_center$o_density*1000
tp_lixels$o_density <- tp_lixels$o_density*1000
wl_lines_center$o_density <- wl_lines_center$o_density*1000
wl_lixels$o_density <- wl_lixels$o_density*1000
nv_lines_center$o_density <- nv_lines_center$o_density*1000
nv_lixels$o_density <- nv_lixels$o_density*1000This tmap plot further reinforces our observation above that the grab ride traffic are from incoming tourists or locals returning home form the airport, as you can see the denser area being the Changi Airport Terminals. However, it is worth highlighting that there some slight traffic along the Changi Village area and infront of the Japanese School as well.
As we have discovered earlier, a huge portion of the grab rides indeed originated from Tampines East, one of the more populated area of Tampines. Particularly along Tampines Avenue 2, there seems to be a higher density, presumably due to it being more convenient to get a ride along the main road.
Surprisingly, the other higher density area in this network density map is the area around Changi General Hospital.
There are 3 main points of to focus on with higher density, mainly:
Along the route to Woodlands Checkpoint, showing that a significant portion of the rides in Woodlands are people coming in from Malaysia.
Around the main hub of Woodlands, along the Woodlands MRT stretch. No surprises here, as the area is perhaps the most dense in terms of human traffic due to concentration of malls, bus interchange, and MRT station.
3 different points around the Sembawang Air Base, which I assume is the entrance. This make sense as well, as military bases in Singapore are generally more inaccessible.
Network KDE indicates that the majority of the traffic is along Moulmein Road, which is the main road next to several of the moderately wealthier estates in Singapore.
We are now going to perform complete spatial randomness (CSR) test by using kfunctions() of spNetwork package. The null hypothesis is defined as:
The CSR test is based on the assumption of the binomial point process which implies the hypothesis that the childcare centres are randomly and independently distributed over the street network.
If this hypothesis is rejected, we may infer that the distribution of Grab ride hailing points are spatially interacting and dependent on each other; as a result, they may form nonrandom patterns.
kfun_cg <- kfunctions(cg_roads,
cg_origin[c("trj_id","PLN_AREA_N", "geometry")],
start = 0,
# A double, the start value for evaluating the k and g functions.
end = 1000,
# A double, the last value for evaluating the k and g functions.
step = 50,
# A double, the jump between two evaluations of the k and g function
width = 50,
# The width of each donut for the g-function
nsim = 50,
# number of Monte Carlo simulations required.
resolution = 50,
verbose = FALSE,
agg = 5,
conf_int = 0.05
# A double indicating the width confidence interval (default = 0.05).
)
kfun_cg$plotk

$plotg

$values
obs_k lower_k upper_k obs_g lower_g upper_g distances
1 0.00000 0.000000 0.000000 14.86145 0.4461755 0.7511913 0
2 36.75689 2.019968 2.496221 43.40340 2.2709191 2.8562247 50
3 79.23030 4.583725 5.556897 41.90507 2.8016060 3.6727370 100
4 121.95096 7.672079 9.409359 42.98638 3.2656802 4.0585737 150
5 166.35078 11.235579 13.685485 47.23408 3.7421175 4.7955567 200
6 214.49640 15.308914 18.505767 49.64395 4.2015786 5.3166485 250
7 264.37654 19.992466 24.131122 49.89859 4.7239620 5.9886796 300
8 316.81416 24.932872 30.210956 52.19405 5.2199586 6.6048004 350
9 369.73892 30.563578 36.891779 54.99879 5.3710826 7.1639038 400
10 423.85570 36.494687 44.055130 52.66643 5.9796380 7.4672589 450
11 477.36355 42.508831 52.146997 55.36046 6.1335298 8.2415155 500
12 531.87151 48.793484 60.498673 54.89546 6.5003607 8.4005740 550
13 587.96637 55.568230 69.424029 55.21653 7.0631545 8.9803438 600
14 643.18290 63.166315 78.573395 55.12058 7.6466148 9.3647043 650
15 698.60978 70.894858 88.092914 53.94332 7.9446187 9.8370821 700
16 749.05825 79.270153 98.843567 53.11297 8.3716039 10.7417962 750
17 802.93515 87.815023 109.878016 49.17157 8.5435789 11.3819049 800
18 852.30969 96.533899 121.149946 50.21966 8.9650285 11.6786172 850
19 900.47377 105.675700 133.278983 47.30420 9.2109970 12.2740715 900
20 946.48263 115.147981 146.065473 45.53648 9.6949997 12.6516046 950
21 991.41387 124.980819 158.995891 42.06376 10.1140504 12.9809774 1000
The blue line represents the empirical network K-function of the Grab ride hailing origin points in Changi planning area. The gray envelop represents the results of the 50 simulations in the interval 2.5% - 97.5%. Because the blue line is above the gray area, we can infer that these origin points in Changi planning area are in clusters, which reinforces our observations made above.
kfun_tp <- kfunctions(tp_roads,
tp_origin[c("trj_id","PLN_AREA_N", "geometry")],
start = 0,
# A double, the start value for evaluating the k and g functions.
end = 1000,
# A double, the last value for evaluating the k and g functions.
step = 50,
# A double, the jump between two evaluations of the k and g function
width = 50,
# The width of each donut for the g-function
nsim = 50,
# number of Monte Carlo simulations required.
resolution = 50,
verbose = FALSE,
agg = 10,
conf_int = 0.05
# A double indicating the width confidence interval (default = 0.05).
)
kfun_tp$plotk

$plotg

$values
obs_k lower_k upper_k obs_g lower_g upper_g distances
1 0.00000 0.000000 0.000000 3.544369 0.4931031 0.7408737 0
2 10.43806 1.620871 1.964641 14.896712 1.9071936 2.3622016 50
3 26.84334 3.873358 4.567299 17.212894 2.5247915 3.0936277 100
4 44.52556 6.756396 7.916164 17.877273 3.0530945 3.7410921 150
5 63.16474 10.317527 11.843465 19.330982 3.6918733 4.4359469 200
6 82.52925 14.456027 16.522763 18.724508 4.3565567 5.2714489 250
7 102.07051 19.215935 22.071392 20.833454 5.1580778 6.1194460 300
8 122.50168 24.821554 28.389847 20.988882 6.0018083 6.9711003 350
9 144.84065 31.594560 35.788070 22.921066 6.8362436 8.2480484 400
10 167.65810 39.226534 44.155280 22.872304 7.6878979 9.1405406 450
11 190.66450 47.813782 53.640048 23.615920 8.7041230 10.2329560 500
12 215.64575 57.096950 64.539668 25.459724 9.7016054 11.6002656 550
13 241.81557 67.730210 76.690484 26.828100 10.8112397 12.8473472 600
14 268.85090 79.241942 89.695240 27.711907 11.8027792 13.9879147 650
15 297.63862 91.640072 104.478276 29.711138 12.9002232 14.8322547 700
16 329.33375 105.425168 120.121957 31.756083 13.8733246 16.2621928 750
17 360.65707 119.826491 136.554511 32.469224 14.8148834 17.5516361 800
18 393.75715 135.278172 154.473841 35.346167 15.9898889 18.4788710 850
19 429.61227 151.940821 173.437282 35.693594 17.0946471 19.7666381 900
20 466.66205 170.017103 193.629671 39.131297 18.3231382 21.0064054 950
21 506.48820 188.550374 214.972837 39.405581 19.4365821 22.2755820 1000
Similar to Changi planning area, as the blue line is above the grey area, we can infer that the Tampines planning area consists of mainly origin points in clusters.
kfun_wl <- kfunctions(wl_roads,
wl_origin[c("trj_id","PLN_AREA_N", "geometry")],
start = 0,
# A double, the start value for evaluating the k and g functions.
end = 1000,
# A double, the last value for evaluating the k and g functions.
step = 50,
# A double, the jump between two evaluations of the k and g function
width = 50,
# The width of each donut for the g-function
nsim = 50,
# number of Monte Carlo simulations required.
resolution = 50,
verbose = FALSE,
agg = 5,
conf_int = 0.05
# A double indicating the width confidence interval (default = 0.05).
)
kfun_wl$plotk

$plotg

$values
obs_k lower_k upper_k obs_g lower_g upper_g distances
1 0.00000 0.000000 0.000000 12.80481 0.8283325 1.169309 0
2 30.08326 2.694329 3.320027 35.47919 3.4987435 4.144916 50
3 67.77057 6.696310 7.833856 39.66965 4.4945029 5.329532 100
4 108.36633 11.794698 13.716184 41.09708 5.4632827 6.603316 150
5 149.89203 18.159981 20.817571 42.13034 6.6163277 7.858348 200
6 193.36561 25.461706 29.251294 44.11650 7.8648538 9.307021 250
7 237.89542 34.440571 39.139047 45.81948 9.3141009 10.895567 300
8 285.19973 44.412707 50.532686 47.25456 10.5875020 12.704352 350
9 332.27061 55.634135 63.959365 48.52127 12.0356010 14.756527 400
10 383.29084 68.848039 79.531978 52.89924 14.0841406 16.859791 450
11 437.26544 84.058053 97.215127 54.76294 16.2578199 19.149808 500
12 492.18911 101.544117 117.474545 55.70436 18.0872695 21.447479 550
13 547.99297 120.409395 139.796854 57.94692 20.1604927 23.949315 600
14 608.33170 141.840801 165.070277 60.72525 22.6043511 27.274700 650
15 669.64247 165.786864 193.269556 62.01109 24.7049366 29.893639 700
16 732.69448 192.257341 224.227073 64.49475 26.8307797 32.114007 750
17 799.31698 220.573532 256.881438 68.91482 29.6441253 33.955511 800
18 871.09049 252.149093 292.669460 73.95102 31.6385143 36.871035 850
19 945.99058 286.000704 330.509849 76.33518 34.3395404 39.320634 900
20 1024.72905 321.252960 370.565822 81.14559 35.9127791 42.329534 950
21 1109.01653 358.614030 413.918286 86.31191 38.8296424 44.251977 1000
Similar to Changi planning area, as the blue line is above the grey area, we can infer that the Woodlands planning area consists of mainly origin points in clusters.
kfun_nv <- kfunctions(nv_roads,
nv_origin[c("trj_id","PLN_AREA_N", "geometry")],
start = 0,
# A double, the start value for evaluating the k and g functions.
end = 1000,
# A double, the last value for evaluating the k and g functions.
step = 50,
# A double, the jump between two evaluations of the k and g function
width = 50,
# The width of each donut for the g-function
nsim = 50,
# number of Monte Carlo simulations required.
resolution = 50,
verbose = FALSE,
agg = 5,
conf_int = 0.05
# A double indicating the width confidence interval (default = 0.05).
)
kfun_nv$plotk

$plotg

$values
obs_k lower_k upper_k obs_g lower_g upper_g distances
1 0.000000 0.0000000 0.0000000 2.070894 0.08958496 0.2059969 0
2 4.899254 0.3517849 0.5415156 5.799959 0.45642204 0.6624189 50
3 10.932279 0.8788552 1.1545293 5.931059 0.57514033 0.7903627 100
4 16.831777 1.5742919 2.0667664 5.841231 0.73051804 1.0077702 150
5 22.590463 2.4164876 3.1404507 6.110714 0.94416240 1.3201036 200
6 28.919677 3.5219758 4.5742957 6.732225 1.14918815 1.6539230 250
7 36.047630 4.8746117 6.3067572 7.460558 1.36392501 2.0769631 300
8 43.869927 6.4028972 8.4839875 8.091780 1.54406605 2.3122146 350
9 52.602640 8.1564804 10.8985329 8.999769 1.87752120 2.6040334 400
10 61.765070 10.2221543 13.7583326 9.453763 2.10949527 2.9575177 450
11 70.978483 12.4049684 16.8102908 9.152719 2.24229466 3.2418104 500
12 80.264729 14.8764452 20.2679305 9.232835 2.54127538 3.5231897 550
13 89.281492 17.7072329 23.8202536 9.490180 2.81464304 3.9288712 600
14 99.725788 20.6885429 27.6858812 10.415163 3.03642046 4.2420544 650
15 110.301184 23.9052257 31.8700331 11.077946 3.31318701 4.4697799 700
16 121.383985 27.3786460 36.4747974 11.230896 3.70490880 4.8441431 750
17 132.750836 31.2936789 41.5554059 11.612056 3.77033739 5.2514026 800
18 144.807176 35.4540386 46.8736938 11.956801 4.07393088 5.5997886 850
19 156.674149 39.9629057 52.4884132 12.357384 4.27883524 5.6366908 900
20 169.582638 44.3949337 58.3363206 13.102711 4.45484906 5.9826490 950
21 182.794599 48.7655389 64.4963187 13.190111 4.52865347 6.3786194 1000
Similar to Changi planning area, as the blue line is above the grey area, we can infer that the Novena planning area consists of mainly origin points in clusters.
The results of our G- and K-Function Analysis on all four planning area shows a spatial pattern of clustering among the grab origin points, which supports the idea that grab rides are commonly booked at the same location within an area, possibly due to designated pickup points or taxi stands.
In conclusion, our analysis of Grab ride-hailing origin points in the specific planning areas of Changi, Tampines, Woodlands, and Novena, and also the whole of Singapore uncovered noteworthy spatial patterns. The observed clustering of origin points within these areas suggests a localized preference for specific pickup locations, potentially driven by factors such as designated pickup points, popular landmarks, transportation hubs, or simply area with higher population density.
These findings hold practical implications for both Grab and urban planners as the identified clusters can guide Grab in optimizing their service by strategically placing vehicles or promoting the use of specific pickup points, ultimately enhancing the efficiency and user experience. Urban planners, on the other hand, can leverage this information to make informed decisions regarding infrastructure development, such as improving the accessibility of popular pickup locations or adjusting traffic flow in areas with high ride-hailing activity.
Moreover, understanding the spatial dynamics of Grab ride-hailing services contributes to a broader perspective on urban mobility patterns. This knowledge can be valuable for city officials, transportation authorities, and policymakers in crafting policies that support sustainable and efficient transportation solutions. By aligning urban planning efforts with the observed ride-hailing patterns, cities can work towards creating more resilient, user-friendly, and accessible transportation systems.
In essence, our analysis not only sheds light on the localized behaviors of Grab users but also opens avenues for strategic decision-making that can enhance the overall urban mobility landscape. As technology continues to shape the future of transportation, such spatial insights play a crucial role in fostering innovation and creating urban environments that are responsive to the evolving needs of their residents.